using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

using WorkflowRelevantData = Scenario.WorkflowEngine.DataModel.WorkflowRelevantData;
using WorkflowDataTypes = Scenario.WorkflowEngine.DataModel.WorkflowDataTypes;
using WorkflowParticipantsData = Scenario.WorkflowEngine.DataModel.WorkflowParticipantsData;
using WorkflowProcesses = Scenario.WorkflowEngine.DataModel.WorkflowProcesses;

using Scenario.WorkflowEngine.DataModel.Common;

namespace Scenario.Modeler.Forms.BPMN
{
	/// <summary>
	/// Descrizione di riepilogo per FormAttribute.
	/// </summary>
	public class ExtendedAttribute : System.Windows.Forms.Form
	{
        public FormExit Exit = FormExit.SAVE;
		public XMLExtendedAttribute xmlAttribute;

		private System.Windows.Forms.Panel panel2;
		private System.Windows.Forms.Button btnCancel;
        private System.Windows.Forms.Button btnSave;
        private System.Windows.Forms.TextBox txtName;
		private System.Windows.Forms.TextBox txtValue;
		private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label lblName;
		/// <summary>
		/// Variabile di progettazione necessaria.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public ExtendedAttribute()
		{
			//
			// Necessario per il supporto di Progettazione Windows Form
			//
			InitializeComponent();

            xmlAttribute = new XMLExtendedAttribute();
		}

		public ExtendedAttribute(XMLExtendedAttribute attribute) : this()
		{
			this.txtName.Text=attribute.Name;
			this.txtValue.Text = attribute.Value;
		}

        public XMLExtendedAttribute XMLExtendedAttribute
        {
            get
            {
                return xmlAttribute;
            }
        }

		/// <summary>
		/// Pulire le risorse in uso.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Codice generato da Progettazione Windows Form
		/// <summary>
		/// Metodo necessario per il supporto della finestra di progettazione. Non modificare
		/// il contenuto del metodo con l'editor di codice.
		/// </summary>
		private void InitializeComponent()
		{
            this.panel2 = new System.Windows.Forms.Panel();
            this.btnCancel = new System.Windows.Forms.Button();
            this.btnSave = new System.Windows.Forms.Button();
            this.lblName = new System.Windows.Forms.Label();
            this.txtName = new System.Windows.Forms.TextBox();
            this.txtValue = new System.Windows.Forms.TextBox();
            this.label1 = new System.Windows.Forms.Label();
            this.panel2.SuspendLayout();
            this.SuspendLayout();
            // 
            // panel2
            // 
            this.panel2.Controls.Add(this.btnCancel);
            this.panel2.Controls.Add(this.btnSave);
            this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.panel2.Location = new System.Drawing.Point(0, 110);
            this.panel2.Name = "panel2";
            this.panel2.Size = new System.Drawing.Size(495, 41);
            this.panel2.TabIndex = 16;
            // 
            // btnCancel
            // 
            this.btnCancel.Location = new System.Drawing.Point(10, 3);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new System.Drawing.Size(60, 35);
            this.btnCancel.TabIndex = 6;
            this.btnCancel.Text = "Cancel";
            this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
            // 
            // btnSave
            // 
            this.btnSave.Location = new System.Drawing.Point(427, 3);
            this.btnSave.Name = "btnSave";
            this.btnSave.Size = new System.Drawing.Size(60, 35);
            this.btnSave.TabIndex = 5;
            this.btnSave.Text = "Save";
            this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
            // 
            // lblName
            // 
            this.lblName.Location = new System.Drawing.Point(7, 14);
            this.lblName.Name = "lblName";
            this.lblName.Size = new System.Drawing.Size(86, 14);
            this.lblName.TabIndex = 18;
            this.lblName.Text = "Attribute";
            // 
            // txtName
            // 
            this.txtName.Location = new System.Drawing.Point(7, 28);
            this.txtName.Name = "txtName";
            this.txtName.Size = new System.Drawing.Size(480, 20);
            this.txtName.TabIndex = 0;
            // 
            // txtValue
            // 
            this.txtValue.Location = new System.Drawing.Point(7, 80);
            this.txtValue.Name = "txtValue";
            this.txtValue.Size = new System.Drawing.Size(480, 20);
            this.txtValue.TabIndex = 4;
            // 
            // label1
            // 
            this.label1.Location = new System.Drawing.Point(7, 63);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(80, 14);
            this.label1.TabIndex = 24;
            this.label1.Text = "Value";
            // 
            // ExtendedAttribute
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(495, 151);
            this.ControlBox = false;
            this.Controls.Add(this.label1);
            this.Controls.Add(this.txtValue);
            this.Controls.Add(this.lblName);
            this.Controls.Add(this.txtName);
            this.Controls.Add(this.panel2);
            this.Name = "ExtendedAttribute";
            this.Text = "Attribute";
            this.panel2.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();

		}
		#endregion

		private void btnSave_Click(object sender, System.EventArgs e)
		{
			xmlAttribute.Name = this.txtName.Text;
			xmlAttribute.Value = this.txtValue.Text;

			this.Close();
		}

		private void btnCancel_Click(object sender, System.EventArgs e)
		{
            Exit = FormExit.CANCEL;
			this.Close();
		}
	}
}
